package com.xxh.driect;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.xxh.utils.MqUtils;

import java.io.IOException;

public class provider {
    public static void main(String[] args) throws IOException {
        Connection connection = MqUtils.getConnection();
        Channel channel = connection.createChannel();
        //声明交换机
        channel.exchangeDeclare("myexchange2","direct");
        //指定路由key
        String routingkey ="warning";
        channel.basicPublish("myexchange2",routingkey,null,("这是direct模式,路由key是："+routingkey).getBytes());
        MqUtils.close(connection,channel);
    }
}
